home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / misc / emu / arosdev.lha / AROS / workbench / c / execute.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  1KB  |  75 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: execute.c,v 1.5 1997/01/27 00:22:37 ldp Exp $
  4.     $Log: execute.c,v $
  5.     Revision 1.5  1997/01/27 00:22:37  ldp
  6.     Include proto instead of clib
  7.  
  8.     Revision 1.4  1996/09/17 16:43:00  digulla
  9.     Use general startup code
  10.  
  11.     Revision 1.3  1996/09/13 17:52:10  digulla
  12.     Use IPTR
  13.  
  14.     Revision 1.2  1996/08/01 17:40:44  digulla
  15.     Added standard header for all files
  16.  
  17.     Desc:
  18.     Lang:
  19. */
  20. #include <exec/memory.h>
  21. #include <proto/exec.h>
  22. #include <dos/dosextens.h>
  23. #include <dos/dostags.h>
  24. #include <proto/dos.h>
  25. #include <utility/tagitem.h>
  26.  
  27. int main (int argc, char ** argv)
  28. {
  29.     STRPTR args[1]={ 0 };
  30.     struct RDArgs *rda;
  31.     BPTR shell;
  32.     STRPTR s1, s2, s3, buf;
  33.     LONG error=0;
  34.  
  35.     rda=ReadArgs("FILE/A",(IPTR *)args,NULL);
  36.     if(rda!=NULL)
  37.     {
  38.     s1=s2=(STRPTR)args[0];
  39.     while(*s2++)
  40.         ;
  41.     buf=(STRPTR)AllocVec(9+2*(s2-s1),MEMF_ANY);
  42.     if(buf!=NULL)
  43.     {
  44.         CopyMem("COMMAND ",buf,8);
  45.         s3=buf+8;
  46.         s2=s1;
  47.         *s3++='\"';
  48.         while(*s1)
  49.         {
  50.         if(*s1=='*'||*s1=='\"'||*s1=='\n')
  51.             *s3++='*';
  52.         if(*s1=='\n')
  53.             *s3++='n';
  54.         else
  55.             *s3++=*s1;
  56.         s1++;
  57.         }
  58.         *s3++='\"';
  59.         *s3=0;
  60.         shell=LoadSeg("c:shell");
  61.         if(shell)
  62.         {
  63.         RunCommand(shell,4096,buf,s3-buf);
  64.         UnLoadSeg(shell);
  65.         }
  66.         FreeVec(buf);
  67.     }
  68.     FreeArgs(rda);
  69.     }else
  70.     error=RETURN_FAIL;
  71.     if(error)
  72.     PrintFault(IoErr(),"Run");
  73.     return error;
  74. }
  75.